package com.qf2207.controller;

import com.qf2207.bo.WaterPowerPriceBo;
import com.qf2207.common.R;
import com.qf2207.pojo.Devices;
import com.qf2207.service.WaterPowerPriceService;
import com.qf2207.vo.BarVo;
import com.qf2207.vo.LayuiPageVo;
import com.qf2207.vo.PieVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/*
 * @Author LX
 * @Date 2022/7/28    8:44
 * @Version 3.3
 */
@RestController
@RequestMapping("/WaterPowerPrice")
public class WaterPowerPriceController {
    @Autowired
    WaterPowerPriceService waterPowerPriceService;
    @RequestMapping("/WaterPowerPriceList")
    public LayuiPageVo<WaterPowerPriceBo> WaterPowerPricePageData(@RequestParam Map<String,Object> params){
        System.out.println(params);
        return waterPowerPriceService.WaterPowerPricePageData(params);
    }
    @RequestMapping("/WaterPowerPriceadd")
    public R adddevices (WaterPowerPriceBo waterPowerPriceBo){
        System.out.println(waterPowerPriceBo);
        int result = waterPowerPriceService.addWaterPowerPriceBo(waterPowerPriceBo);
        if(result == 1){
            return R.ok();
        }else {
            return R.error();
        }
    }
    @RequestMapping("/deleteWaterPowerPrice")
    public R deleteWaterPowerPrice (Integer id){
        int result = waterPowerPriceService.deleteWaterPowerPrice(id);
        if(result == 1){
            return R.ok();
        }else {
            return R.error();
        }
    }

    @RequestMapping("/WaterPowerPriceedit")
    public R WaterPowerPriceEdit (WaterPowerPriceBo waterPowerPriceBo){
        System.out.println(waterPowerPriceBo);
        int result = waterPowerPriceService.WaterPowerPriceedit(waterPowerPriceBo);
        if(result == 1){
            return R.ok();
        }else {
            return R.error();
        }
    }


    @RequestMapping("/echartBar")
    public R echartBar(){

        List<BarVo> list = waterPowerPriceService.sexBarData();
        list.stream().forEach(System.out::println);
        return R.ok().data("sexBar",list);
    }
    @RequestMapping("/echartsPie")
    public R echartsPie(){
        List<PieVo> list = waterPowerPriceService.sexPieData();

        System.out.println("饼状图数据:"+list+"---饼状图向后端发送的数据："+R.ok().data("sexPie",list));
        return R.ok().data("sexPie",list);
    }
}
